package com.jiayang.hhotel.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.SpecialRoomStateModel;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/5/25 0025.
 * 特殊房态历史列表适配器
 */

public class SpecialRoomStateHistoryListAdapter extends SwipeMenuAdapter<SpecialRoomStateHistoryListAdapter.ViewHolder> {

    private Context t;
    private List<SpecialRoomStateModel.PAssignRoomListDtosBean> mList;
    public SpecialRoomStateHistoryListAdapter(Context context,List<SpecialRoomStateModel.PAssignRoomListDtosBean> list){
        this.t = context;
        this.mList = list;
    }

    @Override
    public View onCreateContentView(ViewGroup parent, int viewType) {
        return LayoutInflater.from(t).inflate(R.layout.special_room_state_history_list_item,parent,false);
    }

    @Override
    public SpecialRoomStateHistoryListAdapter.ViewHolder onCompatCreateViewHolder(View realContentView, int viewType) {
        return new ViewHolder(realContentView);
    }

    @Override
    public void onBindViewHolder(SpecialRoomStateHistoryListAdapter.ViewHolder holder, int position) {
        SpecialRoomStateModel.PAssignRoomListDtosBean model = mList.get(position);
        holder.type.setText(model.getStatus()+"");//类型
        holder.roomNum.setText(model.getRoom());//房号
        holder.startDate.setText(model.getBeginDate());//开始日期
        holder.endDate.setText(model.getEndDate());//结束日期
        holder.cause.setText(model.getStatusdescp());//原因
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }


    @Override
    public long getItemId(int position) {
        return position;
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        TextView type;
        TextView roomNum;
        TextView startDate;
        TextView endDate;
        TextView cause;

        public ViewHolder(View itemView) {
            super(itemView);
            type = (TextView) itemView.findViewById(R.id.tv_type);
            roomNum = (TextView) itemView.findViewById(R.id.tv_room_num);
            startDate = (TextView) itemView.findViewById(R.id.tv_start_time);
            endDate = (TextView) itemView.findViewById(R.id.tv_end_time);
            cause = (TextView) itemView.findViewById(R.id.tv_cause);
        }
    }
}
